-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cgen: allow unwrapping of x as string
expr
#22953
base: master
Are you sure you want to change the base?
Conversation
…ath { sin, cos }`" This reverts commit ddf0468.
@@ -145,3 +145,27 @@ fn (mut g Gen) dot_or_ptr(val_type ast.Type) string { | |||
'.' | |||
} | |||
} | |||
|
|||
@[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is too long for @[inline]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
@@ -7801,7 +7782,17 @@ fn (mut g Gen) as_cast(node ast.AsCast) { | |||
g.as_cast_type_names[idx] = variant_sym.name | |||
} | |||
} else { | |||
g.expr(node.expr) | |||
if node.expr is ast.Ident { | |||
if node.expr.info is ast.IdentVar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if it is not a IdentVar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if ast.IdentFn
needs to unwrap the option type as this already works
fn get_opt_fn(a int) ?fn(int) int {
if a < 0 {
return none
}
return fn (n int) int {
return n + n
}
}
fn main() {
d := get_opt_fn(12)
dump(d as fn(int) int)
e := d as fn(int) int
dump(e(12))
}
though dump((d as fn(int) int)(12))
doesn't work due to the parser error. I don't think this would be valid.
Fixes #22947
Huly®: V_0.6-21395